import { apiGet, apiPost, apiPut, apiDelete } from './client'

export interface Student {
  id?: number
  studentNo?: string
  name?: string
  gender?: string
  deptId?: number
  majorId?: number
  classId?: number
  status?: string
  enrollmentDate?: string
  phone?: string
  email?: string
}

export async function listStudents(params: { keyword?: string; classId?: number; offset?: number; limit?: number } = {}) {
  return apiGet<{ total: number; items: Student[] }>('/api/grades/students', params)
}

export async function getStudent(id: number) {
  return apiGet<Student>(`/api/grades/students/${id}`)
}

export async function createStudent(student: Student) {
  return apiPost<Student>('/api/grades/students', student)
}

export async function updateStudent(id: number, student: Student) {
  return apiPut<Student>(`/api/grades/students/${id}`, student)
}

export async function deleteStudent(id: number) {
  return apiDelete<string>(`/api/grades/students/${id}`)
}